<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
	<legend>修改密码</legend>
</fieldset>

<form class="layui-form" action="">
	<div class="layui-form-item">
		<label class="layui-form-label">旧密码</label>
		<div class="layui-input-inline">
			<input type="password" name="oldpassword" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">辅助文字</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">新密码</label>
		<div class="layui-input-inline">
			<input type="password" name="newpassword" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">辅助文字</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">确认密码</label>
		<div class="layui-input-inline">
			<input type="password" name="newpassword2" required lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">辅助文字</div>
	</div>
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>

<script>

	layui.use('form', function() {
		var form = layui.form;

		//监听提交
		form.on('submit(formDemo)', function(data) {
			
			$.ajax({
				url : "admin/modifyPwd.json",
				data : data.field,
				type : "post",
				dataType : "json",
				success : function(data){
					layer.msg(data.message);
					if(data.code > 0){
						//修改成功,跳转到 
						window.location.href="admin/login.do";
					}
				},
				error : function(){
					layer.msg("请求失败");
				}
			});
			
			return false;
		});
	});
</script>